home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / man / line.tex < prev    next >
Encoding:
Text File  |  1994-08-05  |  3.7 KB  |  105 lines

  1. \bigskip
  2. \bigskip
  3. {\magonebf 6.1.3 Straight Lines (line)}
  4.  
  5. {\bf 1. Definition}
  6.  
  7. An instance $l$ of the data type $line$ is a directed straight line 
  8. in the two-dimensional plane. The angle between a right oriented horizontal 
  9. line and $l$ is called the direction of $l$. 
  10.  
  11. \def\name{$line$}
  12. \def\type{$line$}
  13.  
  14. {\bf 2. Creation}
  15.  
  16. a) \create l (point\ p,\ point\ q)
  17.  
  18. b) \create l (segment\ s)
  19.  
  20. c) \create l (point\ p,\ double\ \alpha)
  21.  
  22. d) \create l {}
  23.  
  24.  
  25.  
  26. introduces a variable \var\ of type \name. \var\ is initialized to the line 
  27. passing through points $p$ and $q$ directed form $p$ to $q$ (variant a), to 
  28. the line supporting segment $s$ (variant b), to the line passing through point 
  29. $p$ with direction $\alpha$ (variant c), or a line through $(0,0)$ with 
  30. direction 0 (variant d).
  31.  
  32. \bigskip
  33. {\bf 3. Operations}
  34.  
  35. \medskip
  36. \+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
  37. \+\op double   direction {} 
  38.                         {returns the direction of \var.}
  39. \smallskip
  40. \+\op double   angle {line\ g} 
  41.                         {returns the angle between \var\ and $g$, i.e.,}
  42. \+\nop                  {$g$.direction() - \var.direction().}
  43. \smallskip
  44. \+\op double   angle {} 
  45.                         {returns \var.direction().}
  46. \smallskip
  47. \+\op bool   horizontal {} 
  48.                         {returns true iff \var\ is horizontal.}
  49. \smallskip
  50. \+\op bool   vertical {} 
  51.                         {returns true iff \var\ is vertical.}
  52. \smallskip
  53. \+\op double   slope {}
  54.                         {returns the slope of \var.}
  55. \+\nop                  {\precond  \var\  is not vertical.}
  56. \smallskip
  57. \+\op double   y\_proj {double\ x}        
  58.                        {returns $p$.ycoord(), where $p \in l$ with $p$.xcoord()}
  59. \+\nop                 {= $x$. \precond \var\ is not vertical.}
  60. \smallskip
  61. \+\op double   x\_proj {double\ y}        
  62.                        {returns $p$.xcoord(), where $p \in l$ with $p$.ycoord()}
  63. \+\nop                 {= $y$. \precond \var\ is not horizontal.}
  64. \smallskip
  65. \+\op double   y\_abs {}
  66.                         {returns the y-abscissa of \var\ (\var.y\_proj(0)).}
  67. \+\nop                  {\precond  \var\  is not vertical.}
  68. \smallskip
  69. \+\op bool   intersection {line\ g,\ point\&\ p} {}
  70. \+\nop                     {if $l$ and $g$ are not collinear and intersect the}
  71. \+\nop                     {intersection point is assigned to $p$ and true is}
  72. \+\nop                     {returned, otherwise false is returned.}
  73. \smallskip
  74. \+\op bool   intersection {segment\ s,\ point\&\ p} {}
  75. \+\nop                     {if $l$ and $s$ are not collinear and intersect the}
  76. \+\nop                     {intersection point is assigned to $p$ and true is}
  77. \+\nop                     {returned, otherwise false is returned.}
  78. \smallskip
  79. \+\op line   translate {vector\ v} {}
  80. \+\nop                     {returns $l+v$, i.e., the line created by}
  81. \+\nop                     {translating $l$ by vector $v$. \precond $v$}
  82. \+\nop                     {has dimension 2.}
  83. \smallskip
  84. \+\op line   translate {double\ \alpha,\ double\ d} {}
  85. \+\nop                     {returns the line created by a translation of }
  86. \+\nop                     {\var\ in direction $\alpha$ by distance $d$.}
  87. \smallskip
  88. \+\op line  rotate {point\ q,\ double\ \alpha}
  89.                         {returns the line created by a rotation of $l$}
  90. \+\nop                  {about point $q$ by angle $\alpha$.}
  91. \smallskip
  92. \+\op line  rotate {double\ \alpha}
  93.                         {returns $l$.rotate($point(0,0),\ \alpha$). }
  94. \smallskip
  95. \+\op segment perpendicular {point\ p}
  96.                         {returns the nromal of $p$ with respect to \var.}
  97.  
  98. {\bf 4. Operators }
  99. \medskip
  100. \+&$bool$      &$line$  ==    $line$    &test for equality\cr
  101. \smallskip
  102. \+&$bool$      &$line$\ !=\   $line$    &test for inequality\cr
  103.  
  104. \vfill\eject
  105.